<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/common/template.xhtml">

	<ui:define name="headSection">

	</ui:define>

	<ui:define name="pageContent">

		<h:form>
			<h:panelGroup>
				<table class="mainTable">
					<tr>
						<td><h:outputLabel value="Марка на автомобила">
								<br />
								<h:inputText value="#{pregledNaModelAvtomobil.searchBrand}"
									maxlength="50" />
							</h:outputLabel></td>
						<td><h:outputLabel value="Модел на автомобила">
								<br />
								<h:inputText value="#{pregledNaModelAvtomobil.searchModel}"
									maxlength="50" />
							</h:outputLabel></td>
					</tr>
					<tr>
						<td><h:commandButton value="Търси" class="regButton"
								style="width:80px;height:40px;margin-left:20px;"
								action="#{pregledNaModelAvtomobil.searchIt()}" /> <h:commandButton
								value="Изчисти" class="regButton"
								style="width:80px;height:40px;"
								action="#{pregledNaModelAvtomobil.resetSearch()}" /></td>
					</tr>
				</table>
			</h:panelGroup>
		</h:form>


		<div id="scroolTable" style="margin-top: 10px;">
			<!-- scroll bar -->
			<h:form>

				<!-- за Калин - избрания ред ще има клас = "selectedRow", неизбраните = "notSelectedRow" -->
				<h:dataTable rows="#{configurationProperties.getPageSize()}"
					value="#{pregledNaModelAvtomobil.spisukModeliAvtomobili}" first="0"
					var="curr" rowClasses="#{pregledNaModelAvtomobil.rowStyleClasses}">

					<h:column>
						<f:facet name="header">Марка на автомобила</f:facet>
					#{curr.brand}
				</h:column>

					<h:column>
						<f:facet name="header">Модел на автомобила</f:facet>
					#{curr.model}
				</h:column>

					<h:column>
						<f:facet name="header">Прегледай</f:facet>
						<h:commandButton
							action="#{pregledNaModelAvtomobil.selectRow(curr)}"
							value="Прегледай" class="inTableButton"/>
					</h:column>

					<h:column rendered="#{pregledNaModelAvtomobil.choosingAlowed}">
						<f:facet name="header">Избери</f:facet>
						<h:commandButton
							action="#{pregledNaModelAvtomobil.chooseVehicleModel(curr)}"
							value="Избери" class="inTableButton"/>
					</h:column>

					<f:facet name="footer">

						<!-- предишна страница -->
						<h:commandLink disabled="#{pregledNaModelAvtomobil.page - 1 lt 0}"
							action="#{pregledNaModelAvtomobil.setPage(pregledNaModelAvtomobil.page - 1)}"
							value="&lt;&lt;" />

						<h:outputText value=" " />

						<!-- други страници -->
						<ui:repeat value="#{pregledNaModelAvtomobil.pagesList}"
							var="currPage">
							<h:commandLink
								disabled="#{pregledNaModelAvtomobil.getPage() eq currPage.intValue() - 1}"
								action="#{pregledNaModelAvtomobil.setPage(currPage.intValue() - 1)}"
								value="#{currPage}" />

							<h:outputText value=" " />
						</ui:repeat>

						<!-- следваща страница -->
						<h:commandLink
							disabled="#{pregledNaModelAvtomobil.page + 1 ge pregledNaModelAvtomobil.pagesCount}"
							action="#{pregledNaModelAvtomobil.setPage(pregledNaModelAvtomobil.page + 1)}"
							value="&gt;&gt;" />

					</f:facet>

				</h:dataTable>
			</h:form>
		</div>

		<h:form>
			<table class="mainTable">
				<tr>
					<td><h:outputLabel value="Марка на автомобила*">
							<br />
							<h:inputText id="brand" value="#{pregledNaModelAvtomobil.brand}"
								readonly="true" />
						</h:outputLabel></td>
					<td><h:outputLabel value="Модел на автомобила*">
							<br />
							<h:inputText id="model" value="#{pregledNaModelAvtomobil.model}"
								readonly="true" />
						</h:outputLabel></td>
					<td><h:outputLabel value="Характеристики">
							<br />
							<h:inputTextarea id="characteristics"
								value="#{pregledNaModelAvtomobil.characteristics}"
								readonly="true" />
						</h:outputLabel></td>
				</tr>
			</table>
		</h:form>

		<h:form>
			<!-- формата е разделена на две, за да не се проверяват данните
			при натискането на бутоните "Отмени" и "Добави" -->
			<table class="buttonTable">
				<tr>
					<td><h:commandButton
							action="#{pregledNaModelAvtomobil.deselectRow()}" value="Отмени"
							class="regButton"
							style="width:80px;height:40px;margin-left:-40px;"
							disabled="#{!pregledNaModelAvtomobil.rowSelected}" /></td>
				</tr>
			</table>
		</h:form>

	</ui:define>

</ui:composition>
</html>